package com.bawei.library_base.mvvm.adapter;

import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;

/**
 * @author : zhiyu
 * @date :
 * @content :
 */
public class HomeFragmentAdapter extends FragmentPagerAdapter {

    private static final String TAG = "li";
    private ArrayList<Fragment> fragments;
    private ArrayList<String> strings;

    public HomeFragmentAdapter(@NonNull @NotNull FragmentManager fm, ArrayList<Fragment> fragments, ArrayList<String> strings) {
        super(fm);
        this.fragments = fragments;
        this.strings = strings;
    }

    @NonNull
    @NotNull
    @Override
    public Fragment getItem(int position) {
        if (fragments!=null&&fragments.size()>0){
            return fragments.get(position);
        }
        return null;
    }

    @Override
    public int getCount() {
        if (fragments!=null&&fragments.size()>0){
            return fragments.size();
        }
        return 0;
    }

    @Nullable
    @org.jetbrains.annotations.Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return strings.get(position);
    }


    @Override
    public void destroyItem(@NonNull @NotNull ViewGroup container, int position, @NonNull @NotNull Object object) {

    }
}
